home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / cd_lib / src / cdr_rdmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  860 b   |  40 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include "define.h"
  5.  
  6. /* ドライブモードの読み取り */
  7. /*
  8.  * decice_no: device number (Towns CD-ROM -> 0)
  9.  * return: 0 -> 正常終了, 0以外 -> エラー
  10.  *           sector_size <- 2048 , 2336 or 2340 (bytes / sector)
  11.  */
  12. int cdr_rdrvmd(int device_no, int *sector_size)
  13. {
  14.     union REGS reg;
  15.     
  16.     if (sector_size) {
  17.         return -1;
  18.     }
  19.     reg.h.ah = 0x01;
  20.     reg.h.al = (0xC0 | (u_char) device_no);
  21.     reg.h.ch = 0x00;
  22.     
  23.     int86(0x93, ®, ®);
  24.     
  25.     if (reg.h.dl == 0x04)
  26.         *sector_size = 2048;
  27.     else if (reg.h.dl == 0x08)
  28.         *sector_size = 2336;
  29.     else if (reg.h.al == 0x09)
  30.         *sector_size = 2340;
  31.     
  32.     if (reg.h.ah == 0) {
  33.         return 0;
  34.     } else if (reg.h.ah == 0x02) {  /* device number error */
  35.         return DEVERR;
  36.     } else {                        /* hard ware error */
  37.         return reg.x.cx;
  38.     }
  39. }
  40.